<?php
namespace app\common\model;

class ErrorModel extends Model {

    /**
     * 错误日志
     *
     * @param $type
     * @param $data
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     */
    public function addError($data, $type) {
        $data = [
            'message' => is_array($data)?json_encode($data):$data,
            'type' => $type,
            'created_time' => date('Y-m-d H:i:s', time()),
        ];
        $this->save($data);
    }

}